
import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import {defHttp} from "@/utils/http/axios";
import type { AxiosRequestConfig } from 'axios';
export interface MailAccountVO {
  id: number
  mail: string
  username: string
  password: string
  host: string
  port: number
  sslEnable: boolean
  starttlsEnable: boolean
}
const  MODULAR = 'system/mail-account'
export const Api = {
  GetSimpleMailAccountList: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/simple-list`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetMailAccountPage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetMailAccount: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateMailAccount: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateMailAccount: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteMailAccount: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,

}

// 获得邮箱账号精简列表
export const getSimpleMailAccountList =() => {
  return defHttp.request({ ...Api.GetSimpleMailAccountList })
}

// 查询邮箱账号列表
export const getMailAccountPage = (params: PageParam) => {
 return defHttp.request({ ...Api.GetMailAccountPage,params })
}

// 查询邮箱账号详情
export const getMailAccount = (id: number) => {
  let params = { id: id }
  return defHttp.request({ ...Api.GetMailAccount,params:params })
}

// 新增邮箱账号
export const createMailAccount = (data: MailAccountVO) => {
  let params = { data: data }
  return defHttp.request({ ...Api.CreateMailAccount,params:params })
}

// 修改邮箱账号
export const updateMailAccount  = (data: MailAccountVO) => {
  let params = { data: data }
  return defHttp.request({ ...Api.UpdateMailAccount,params:params })
}

// 删除邮箱账号
export const deleteMailAccount = (id: number) => {
  let params = { id: id }
  return defHttp.request({ ...Api.DeleteMailAccount,params:params })

}
